//api的上传图片
export const upload = (sourceType) => {
  if (sourceType == 1) { // 拍照
    api.getPicture({
      sourceType: 'camera',
      encodingType: 'jpg',
      mediaValue: 'pic',
      allowEdit: false,
      destinationType: 'base64',
      quality: 100,
      targetWidth: 200,
      targetHeight: 200,
      saveToPhotoAlbum: true
    }, function (ret, err) {
      if (ret) {
        // 上传的loading
        // api.showProgress({
        //   style: 'default',
        //   animationType: 'fade',
        //   text: '图片上传中...',
        //   modal: false
        // });
        //返回base64格式的路径
        return ret.base64Data
      }
    });
  } else if (sourceType == 2) { // 从相机中选择
    api.getPicture({
      sourceType: 'library',
      encodingType: 'jpg',
      mediaValue: 'pic',
      destinationType: 'base64',
      quality: 100,
      targetWidth: 200,
      targetHeight: 200
    }, function (ret, err) {
      if (ret && ret.data) {
        return ret.base64Data
      }
    });
  }

}
